package zpin.action;

import java.util.List;

import util.dao.Pagination;
import zpin.dao.CityDao;
import zpin.dao.ResumeDao;
import zpin.dao.TypeDao;
import zpin.model.City;
import zpin.model.Engage;
import zpin.model.Resume;
import zpin.model.Type;

import com.opensymphony.xwork2.ActionSupport;

public class AdminResumeAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private Resume resume;
	
	private City city;
	
	private Type type;
	
	private ResumeDao resumeDao;
	
	private CityDao cityDao;
	
	private TypeDao typeDao;
	
	private List<Resume> resumelist;
	
	private Pagination<Resume> pagination;

	public Resume getResume() {
		return resume;
	}

	public void setResume(Resume resume) {
		this.resume = resume;
	}

	public City getCity() {
		return city;
	}

	public void setCity(City city) {
		this.city = city;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public ResumeDao getResumeDao() {
		return resumeDao;
	}

	public void setResumeDao(ResumeDao resumeDao) {
		this.resumeDao = resumeDao;
	}

	public CityDao getCityDao() {
		return cityDao;
	}

	public void setCityDao(CityDao cityDao) {
		this.cityDao = cityDao;
	}

	public TypeDao getTypeDao() {
		return typeDao;
	}

	public void setTypeDao(TypeDao typeDao) {
		this.typeDao = typeDao;
	}

	public List<Resume> getResumelist() {
		return resumelist;
	}

	public void setResumelist(List<Resume> resumelist) {
		this.resumelist = resumelist;
	}

	public Pagination<Resume> getPagination() {
		return pagination;
	}

	public void setPagination(Pagination<Resume> pagination) {
		this.pagination = pagination;
	}
	
	public String show(){
		if (pagination == null) {
			this.pagination = new Pagination<Resume>();
		}

		if (this.pagination.getSize() == 0) {
			this.pagination.setSize(5);
		}
		if (this.pagination.getNo() == 0) {
			this.pagination.setNo(1);
		}
		resumeDao.browse(pagination);
		resumelist = pagination.getResults();

		return SUCCESS;
	}
	
	public String delete(){
		resumeDao.delete(resume);
		return SUCCESS;
	}
	
	public String detail(){
		this.resume = resumeDao.findById(resume.getId());
		
		return SUCCESS;
	}
}
